<?php require_once 'header.php';?>    <!-- DataTables Responsive CSS -->
	<style>table tr td{padding:3px;}</style>
        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">
                <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                        	<?php echo XXF_BACK?>
                            <span class="xxf_red">培训学员信息修改</span>
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                        	
							<table border="1" align="center">
								<tr>
									<td colspan="4" align="center" valign="middle">报名表修改[*号必填选项]</td>
								</tr>
								<tr>
									<td><strong>身份证<span class="xxf_red">*</span></strong></td><td><input type="text" name="x" id="idcard" value="<?php echo $result['idcard']?>"></td>
									<td><strong>家庭地址</strong></td><td><input type="text" name="x" id="home" value="<?php echo $result['home']?>"></td>
								</tr>
								<tr>
									<td><strong>姓名<span class="xxf_red">*</span></strong></td><td><input type="text" name="x" id="puname" value="<?php echo $result['puname']?>"></td>
									<td><strong>民族<span class="xxf_red">*</span></strong></td><td>
										<select id="minzu" name="x">
											<?php foreach (explode(",",gconf('web', 'minzu')) as $row){?>
												<option value="<?php echo $row;?>" <?php echo ($row==$result['minzu'])?"selected":""?>><?php echo $row;?></option>
											<?php }?>
										</select>
									</td>
								</tr>
								<tr>
									<td><strong>职务<span class="xxf_red">*</span></strong></td><td>
										<select id="zhiwu" name="x">
											<option value="无">无</option>
											<?php foreach (explode(",",gconf('web', 'zhiwu')) as $row){?>
												<option value="<?php echo $row;?>" <?php echo ($row==$result['zhiwu'])?"selected":""?>><?php echo $row;?></option>
											<?php }?>
										</select>
										<select id="ptype" name="x">
											<?php foreach (explode(",",gconf('web', 'ptype')) as $row){?>
												<option value="<?php echo $row;?>" <?php echo ($row==$result['ptype'])?"selected":""?>><?php echo $row;?></option>
											<?php }?>
										</select>
									</td>
									<td><strong>手机号码<span class="xxf_red">*</span></strong></td><td><input type="text" name="x" id="mphone" value="<?php echo $result['mphone']?>"></td>
								</tr>
								<tr>
									<td><strong>职称<span class="xxf_red">*</span></strong></td><td>
										<select id="zhicheng" name="x">
											<option value="无">无</option>
											<?php foreach (explode(",",gconf('web', 'zhicheng')) as $row){?>
												<option value="<?php echo $row;?>" <?php echo ($row==$result['zhicheng'])?"selected":""?>><?php echo $row;?></option>
											<?php }?>
										</select>
									</td>
									<td><strong>单位名称<span class="xxf_red">*</span></strong></td><td><input type="text"  name="x" id="workunit" value="<?php echo $result['workunit']?>"></td>
								</tr>
								<tr>
									<td><strong>专业<span class="xxf_red">*</span></strong></td><td>
										<select id="zhuanye" name="x">
											<option value="无">无</option>
											<?php foreach (explode(",",gconf('web', 'zhuanye')) as $row){?>
												<option value="<?php echo $row;?>" <?php echo ($row==$result['zhuanye'])?"selected":""?>><?php echo $row;?></option>
											<?php }?>
										</select>
									</td><td><strong>单位地址<span class="xxf_red">*</span></strong></td>
									<td>
										<input type="text"  name="x" id="address" value="<?php echo $result['address']?>">
									</td>
								</tr>
								<tr>
									<td><strong>学历<span class="xxf_red">*</span></strong></td>
									<td>
										<select id="wenhua" name="x">
											<option value="无">无</option>
											<?php foreach (explode(",",gconf('web', 'wenhua')) as $row){?>
												<option value="<?php echo $row;?>" <?php echo ($row==$result['wenhua'])?"selected":""?>><?php echo $row;?></option>
											<?php }?>
										</select>
									</td>
									<td><strong>证书编号</strong></td>
									<td><input type="text"  name="x" id="zhengshuid" value="<?php echo $result['zhengshuid']?>"></td>
								</tr>
								<tr>
									<td><strong>政治面貌</strong></td>
									<td>
										<select id="zhengzhi" name="x">
											<option value="无">无</option>
											<?php foreach (explode(",",gconf('web', 'zhengzhi')) as $row){?>
												<option value="<?php echo $row;?>" <?php echo ($row==$result['zhengzhi'])?"selected":""?>><?php echo $row;?></option>
											<?php }?>
										</select>
									</td>
									<td><strong>学号</strong></td>
									<td><input type="text" name="x" id="xuehao" value="<?php echo $result['xuehao']?>" ></td>
								</tr>
								<tr>
									<td><strong>备注</strong></td>
									<td colspan="2">
										<textarea id="beizhu" name="x" style="width:100%;height:100px;"><?php echo $result['beizhu']?></textarea>
									</td>
									<td  align="center" valign="middle"><img src="uploader/xueyuanimg/<?php echo $result['idcard']?>.jpg" width="102" height="126"></td>
								</tr>

								<tr>
									<td colspan="4">
										<input type="button" value="确认修改" id="sub" name="sub" onClick="upd(<?php echo $result['id']?>)">
									</td>
								</tr>
							</table>
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
             </div>
        </div>
        <!-- /#page-wrapper -->
        <!-- DataTables JavaScript -->
<?php require_once 'bottom.php';?>
<script>
    var Wi = [ 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1 ];    // 加权因子   
	var ValideCode = [ 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2 ];            // 身份证验证位值.10代表X   
	function IdCardValidate(idCard) { 
		idCard = trim(idCard.replace(/ /g, ""));               //去掉字符串头尾空格                     
		if (idCard.length == 15) {   
			return isValidityBrithBy15IdCard(idCard);       //进行15位身份证的验证    
		} else if (idCard.length == 18) {   
			var a_idCard = idCard.split("");                // 得到身份证数组   
			if(isValidityBrithBy18IdCard(idCard)&&isTrueValidateCodeBy18IdCard(a_idCard)){   //进行18位身份证的基本验证和第18位的验证
				return true;   
			}else {   
				return false;   
			}   
		} else {   
			return false;   
		}   
	}   
	/**  
	 * 判断身份证号码为18位时最后的验证位是否正确  
	 * @param a_idCard 身份证号码数组  
	 * @return  
	 */  
	function isTrueValidateCodeBy18IdCard(a_idCard) {   
		var sum = 0;                             // 声明加权求和变量   
		if (a_idCard[17].toLowerCase() == 'x') {   
			a_idCard[17] = 10;                    // 将最后位为x的验证码替换为10方便后续操作   
		}   
		for ( var i = 0; i < 17; i++) {   
			sum += Wi[i] * a_idCard[i];            // 加权求和   
		}   
		valCodePosition = sum % 11;                // 得到验证码所位置   
		if (a_idCard[17] == ValideCode[valCodePosition]) {   
			return true;   
		} else {   
			return false;   
		}   
	}   
	/**  
	  * 验证18位数身份证号码中的生日是否是有效生日  
	  * @param idCard 18位书身份证字符串  
	  * @return  
	  */  
	function isValidityBrithBy18IdCard(idCard18){   
		var year =  idCard18.substring(6,10);   
		var month = idCard18.substring(10,12);   
		var day = idCard18.substring(12,14);   
		var temp_date = new Date(year,parseFloat(month)-1,parseFloat(day));   
		// 这里用getFullYear()获取年份，避免千年虫问题   
		if(temp_date.getFullYear()!=parseFloat(year)   
			  ||temp_date.getMonth()!=parseFloat(month)-1   
			  ||temp_date.getDate()!=parseFloat(day)){   
				return false;   
		}else{   
			return true;   
		}   
	}   
	  /**  
	   * 验证15位数身份证号码中的生日是否是有效生日  
	   * @param idCard15 15位书身份证字符串  
	   * @return  
	   */  
	  function isValidityBrithBy15IdCard(idCard15){   
		  var year =  idCard15.substring(6,8);   
		  var month = idCard15.substring(8,10);   
		  var day = idCard15.substring(10,12);   
		  var temp_date = new Date(year,parseFloat(month)-1,parseFloat(day));   
		  // 对于老身份证中的你年龄则不需考虑千年虫问题而使用getYear()方法   
		  if(temp_date.getYear()!=parseFloat(year)   
				  ||temp_date.getMonth()!=parseFloat(month)-1   
				  ||temp_date.getDate()!=parseFloat(day)){   
					return false;   
			}else{   
				return true;   
			}   
	  }   
	//去掉字符串头尾空格   
	function trim(str) {   
		return str.replace(/(^\s*)|(\s*$)/g, "");   
	}  
</script>
<script>
function upd(id){
	var idcard=$("#idcard").val();
	var puname=$("#puname").val();
	var mphone=$("#mphone").val();
	if(idcard.length!=18||puname.length<2||mphone.length<8){
		alert("请将信息填写正确完整!");return;
	}
	if(!IdCardValidate(idcard)){
		alert("身份证信息不合法，请检查后重新输入!");return;
	}
	$.xloading(1);
	$.xtodb("upd","peixunxueyuan",$("[name='x']"),id,function(data1){
		$.xloading(0);
		if(data1==0){
			$.xalert("处理失败,检查填写是否正确，不要重复提交!");
		}else if(data1==1){
			alert("处理成功！");
		}else{
			alert(data1);
		}
	}); 
}
</script>